﻿
'alias = name_defination,name_defination,...,name_defination

Imports std

Public Class aliases
    Inherits x_separated_names
    Public Const aliasSeparator As Char = character.comma

    Private Shared _empty As aliases = Nothing

    Public Shared Function empty() As aliases
        Return _empty
    End Function

    Shared Sub New()
        _empty = New aliases(New vector(Of String)())
    End Sub

    Private Shared Function isAliasSeparator(ByVal c As Char) As Boolean
        Return c = aliasSeparator
    End Function

    Protected Friend Shared Function _isMeaningfulMark(ByVal c As Char) As Boolean
        Return isAliasSeparator(c)
    End Function

    Private Sub New(ByVal v As vector(Of String))
        MyBase.New(v)
    End Sub

    Public Function aliases() As vector(Of String)
        Return +Me
    End Function

    Public Shared Function create(ByVal v As vector(Of String)) As aliases
        Dim _v As vector(Of String) = Nothing
        copy(_v, v)
        Return internalCreate(_v)
    End Function

    Protected Shared Function internalCreate(ByVal v As vector(Of String)) As aliases
        Return New aliases(v)
    End Function

    Protected Overloads Shared Function parseImpl(ByVal input As String, ByRef index As Int64, _
                                                  ByRef output As aliases) As Boolean
        Return parseImpl(input, index, output, _
                         AddressOf isAliasSeparator, _
                         AddressOf function_name_defination.parse, _
                         AddressOf internalCreate)
    End Function

    Public Shared Function parse(ByVal input As String, ByRef index As Int64, ByRef output As aliases) As Boolean
        Return parsebase(input, index, output, AddressOf parseImpl)
    End Function
End Class
